﻿$(function() {
    $("#index").click(createOpt.createIndex);
    $("#navBtn").click(createOpt.createNav);
    $("#hotTag").click(createOpt.createHotTag);
    $("#catogryBtn").click(createOpt.createCategory);
    $("#postBtn").click(createOpt.createPosts);
 
});

var createOpt = (function(){
    function createIndex(){
        $.ajax({
            type: "post",
            url: "/admin/staticmgr/indexcreate",
            dataType: "json",
            success: function (data){
                if(data.success){

                    $.layer({
                        area : ['auto','auto'],
                        dialog : {msg:'首页生成成功！',type : 1}
                    });
                }
            }
        });
    };
    function createNav(){
        $.ajax({
            type: "post",
            url: "/admin/staticmgr/navcreate",
            dataType: "json",
            success: function (data){
                if(data.success){
                    $.layer({
                        area : ['auto','auto'],
                        dialog : {msg:'导航生成成功！',type : 1}
                    });
                }
            }
        });
    };
    function createHotTag(){
        $.ajax({
            type: "post",
            url: "/admin/staticmgr/hottagcreate",
            dataType: "json",
            success: function (data){
                if(data.success){
                    $.layer({
                        area : ['auto','auto'],
                        dialog : {msg:'热门标签生成成功！',type : 1}
                    });
                }
            }
        });
    }
    function createCategory(){
        $.ajax({
            type: "post",
            url: "/admin/staticmgr/categorycreate",
            dataType: "json",
            success: function (data){
                if(data.success){
                    $.layer({
                        area : ['auto','auto'],
                        dialog : {msg:'所有分类列表生成成功！',type : 1}
                    });
                }
            }
        });
    }
    function createPosts(){
        $.ajax({
            type: "post",
            url: "/admin/staticmgr/postcreate",
            dataType: "json",
            success: function (data){
                if(data.success){
                    $.layer({
                        area : ['auto','auto'],
                        dialog : {msg:'所有文章生成成功！',type : 1}
                    });
                }
            }
        });
    }
    return {
        "createIndex":createIndex,
        "createNav":createNav,
        "createHotTag":createHotTag,
        "createCategory":createCategory,
        "createPosts":createPosts,
        "postSyn":function (){
        	$.ajax({
	            type: "post",
	            url: "/admin/staticmgr/postsyn",
	            dataType: "json",
	            success: function (data){
	                if(data.success){
	                    $.layer({
	                        area : ['auto','auto'],
	                        dialog : {msg: "同步成功，共同步"+data.total+"篇文章！",type : 1}
	                    });
	                }
	            }
        	});
        }
    }

})();

